Merge "Fix the (un)watch token to include the namespace name."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 16 Aug 2014 13:20:31 +0000 (13:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 16 Aug 2014 13:20:31 +0000 (13:20 +0000)
1  2 
includes/actions/WatchAction.php

@@@ -1,6 -1,6 +1,6 @@@
  <?php
  /**
 - * Performs the watch and unwatch actions on a page
 + * Performs the watch actions on a page
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
@@@ -82,10 -82,17 +82,10 @@@ class WatchAction extends FormAction 
        protected function checkCanExecute( User $user ) {
                // Must be logged in
                if ( $user->isAnon() ) {
 -                      $loginreqlink = Linker::linkKnown(
 -                              SpecialPage::getTitleFor( 'Userlogin' ),
 -                              $this->msg( 'loginreqlink' )->escaped(),
 -                              array(),
 -                              array( 'returnto' => $this->getPageTitle(), 'returntoquery' => 'action=' . $this->getName() )
 -                      );
 -                      $reasonMsg = $this->msg( 'watchlistanontext' )->rawParams( $loginreqlink );
 -                      throw new UserNotLoggedIn( $reasonMsg, 'watchnologin' );
 +                      throw new UserNotLoggedIn( 'watchlistanontext', 'watchnologin' );
                }
  
 -              return parent::checkCanExecute( $user );
 +              parent::checkCanExecute( $user );
        }
  
        /**
                if ( $action != 'unwatch' ) {
                        $action = 'watch';
                }
-               $salt = array( $action, $title->getDBkey() );
+               $salt = array( $action, $title->getPrefixedDBkey() );
  
                // This token stronger salted and not compatible with ApiWatch
                // It's title/action specific because index.php is GET and API is POST
                $this->getOutput()->addWikiMsg( 'addedwatchtext', $this->getTitle()->getPrefixedText() );
        }
  }
 -
 -/**
 - * Page removal from a user's watchlist
 - *
 - * @ingroup Actions
 - */
 -class UnwatchAction extends WatchAction {
 -
 -      public function getName() {
 -              return 'unwatch';
 -      }
 -
 -      protected function getDescription() {
 -              return $this->msg( 'removewatch' )->escaped();
 -      }
 -
 -      public function onSubmit( $data ) {
 -              wfProfileIn( __METHOD__ );
 -              self::doUnwatch( $this->getTitle(), $this->getUser() );
 -              wfProfileOut( __METHOD__ );
 -
 -              return true;
 -      }
 -
 -      protected function alterForm( HTMLForm $form ) {
 -              $form->setSubmitTextMsg( 'confirm-unwatch-button' );
 -      }
 -
 -      protected function preText() {
 -              return $this->msg( 'confirm-unwatch-top' )->parse();
 -      }
 -
 -      public function onSuccess() {
 -              $this->getOutput()->addWikiMsg( 'removedwatchtext', $this->getTitle()->getPrefixedText() );
 -      }
 -}